class RouteState {
  constructor() {
    this.path = 'home'
    this.id = ''
    this.page = null // 当前页面
    this.pageStack = [] // 页面栈
    this.query = {}
  }

  update = (page = null) => {
    if (!page) {
      return
    }
    if (this.page) {
      this.page._execute_onHide()
      this.page.visible = false
    }
    page.visible = true
    page.$route = this
    this.page = page
    this.pageStack.push(page)
    this.id = page.id
    this.query = page.query
    this.path = page.path
    this.page._execute_onShow()
  }
  pop = () => {
    const odlPage = this.pageStack.pop()
    const newPAge = this.pageStack[this.pageStack.length - 1]
    this.update(newPAge)
    return odlPage
  }
}
export default new RouteState()